<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:perm="http://www.coopservice.it/commons2/permissions"
	xmlns:coop="http://www.coopservice.it/commons2/taglib"
	xmlns:p="http://primefaces.org/ui" template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Configurazione" />
	</ui:define>

	<ui:define name="content">

		<h:form>
			<h:panelGrid columns="2">

				<h:outputLabel value="Identificativo:" for="id"
					rendered="#{not empty ruleController.element.id}" />
				<h:outputText id="id" value="#{ruleController.element.id}"
					rendered="#{not empty ruleController.element.id}" />

				<h:outputLabel value="Nome:" for="nome" />
				<h:panelGroup id="nome">
					<h:inputText value="#{ruleController.element.name}"
						rendered="#{empty ruleController.element.id}" style="width: 100%;"
						required="true"
						requiredMessage="E' obbligatorio specificare il nome del file di regole" />
					<h:outputText value="#{ruleController.element.name}"
						rendered="#{not empty ruleController.element.id}" />
				</h:panelGroup>

				<h:outputLabel value="Tipologia:" for="type" />
				<h:panelGroup id="type">
					<h:selectOneMenu style="width: 100%;" required="true"
						requiredMessage="E' obbligatorio specificare la tipologia di appartenenza"
						value="#{ruleController.element.type.id}"
						rendered="#{empty ruleController.element.id}">
						<f:selectItems value="#{tipologieItems}" />
					</h:selectOneMenu>
					<h:outputText value="#{ruleController.element.type.name}"
						rendered="#{not empty ruleController.element.id}" />
				</h:panelGroup>

				<h:outputLabel value="File:" for="file"
					rendered="#{not empty ruleController.element.id}" />

				<h:outputText value="#{ruleController.element.path}" id="file"
					rendered="#{not empty ruleController.element.id}" />

				<h:outputLabel value="Attiva:" for="attivo" />
				<h:selectOneMenu id="attivo" style="width: 100%;"
					value="#{ruleController.element.attivo}">
					<f:selectItems value="#{siNoItems}" />
				</h:selectOneMenu>

				<h:outputLabel value="Contenuto:" for="body" />
				<h:inputTextarea id="body" rows="10" cols="80"
					value="#{ruleController.element.body}" />

				<h:outputLabel value="Creata il:" for="dateCreated"
					rendered="#{not empty ruleController.element.id}" />
				<h:outputText value="#{ruleController.element.dateCreated}"
					rendered="#{not empty ruleController.element.id}" id="dateCreated">
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss.SSS" />
				</h:outputText>

				<h:outputLabel value="Ultima modifica il:" for="dateModified"
					rendered="#{not empty ruleController.element.id}" />
				<h:outputText value="#{ruleController.element.dateModified}"
					rendered="#{not empty ruleController.element.id}" id="dateModified">
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss.SSS" />
				</h:outputText>

			</h:panelGrid>

			<coop:spacer></coop:spacer>
			<coop:spacer></coop:spacer>
			<coop:spacer></coop:spacer>

			<h:panelGrid columns="3">
				<h:commandButton action="#{ruleController.save}" value="Salva"
					rendered="#{empty ruleController.element.id}" />
				<h:commandButton action="#{ruleController.update}"
					onclick="if (!confirm('Confermi le modifiche?')) return false"
					value="Salva le modifiche"
					rendered="#{not empty ruleController.element.id}" />
				<h:commandButton action="#{ruleController.listPage}" value="Annulla"
					immediate="true" />
				<h:commandButton action="#{ruleController.delete}" immediate="true"
					onclick="if (!confirm('Confermi l\'eliminazione?')) return false"
					value="Elimina" />
			</h:panelGrid>
		</h:form>

	</ui:define>
</ui:composition>